import json


path='/root/project/weights/faiss/faiss/img_ap_ar.json'
ok_path='/root/project/weights/faiss/faiss/img_ap_ar.jsonv2'

with open(ok_path,'w') as ff:
    with open(path,'r') as fff:
        old_key_value=json.loads(fff.read())
        new_key_value={}
        for oldkey in old_key_value:
            new_key=oldkey.replace('/mnt/hwfile/opendatalab/ouyanglinke/PDF_Formula/','/root/project/weights/faiss/')
            new_key_value[new_key]=old_key_value[oldkey]
        ff.write(json.dumps(new_key_value,ensure_ascii=False))

        # for ii in fff:
        #     okii=ii.replace('/mnt/hwfile/opendatalab/ouyanglinke/PDF_Formula/','/root/project/weights/faiss/')
        #     ff.write(okii)
    
    
    
    
    




